import { h } from 'vue'
import { Modal } from 'ant-design-vue'

export default function (list) {
  return new Promise((resolve) => {
    const contentItem = list.map((item) => {
      return h('div', { class: 'list-item', onClick: () => onClickItem(resolve, item) }, item.organizationName)
    })
    Modal.confirm({
      title: null,
      icon: null,
      centered: true,
      maskClosable: true,
      wrapClassName: 'choose-org-modal',
      closable: false,
      width: 560,
      footer: null,
      zIndex: 99999,
      content: h('div', { class: 'org-list' }, contentItem)
    })
  })
}

const onClickItem = (resolve, item) => {
  resolve(item)
  Modal.destroyAll()
}
